package se.webbzon.boltzmann.battle.property;

import se.webbzon.boltzmann.battle.battleaction.BattleActionFactory;

public class BattleBuff {
	
	// The type of the battle buff
	private BattleBuffType type;
	
	// The remaining duration of the buff (number of rounds)
	private int duration;
	
	// The battle action factory used in the beginning of each round
	private final BattleActionFactory buffActionFactory;
	
	/*============================================================
	Constructors
	============================================================*/
	
	/** Creates a new battle buff of a given type and with a given duration. **/
	public BattleBuff(BattleBuffType type, int duration) {
		this(type,duration,null);
	}
	
	/** Creates a new battle buff of a given type and with a given duration. 
	 * The given battle action factory will be used in the beginning of 
	 * each round. **/
	public BattleBuff(	BattleBuffType type, 
						int duration, 
						BattleActionFactory buffActionFactory) {
		this.type = type;
		this.duration = duration;
		this.buffActionFactory = buffActionFactory;
	}
	
	/*============================================================
	Public Methods
	============================================================*/
	
	/** Returns the type of the buff. **/
	public BattleBuffType getType() {
		return type;
	}
	
	/** Returns the remaining duration of this buff. If the duration is
	 * zero then the buff is permanent.  **/
	public int getDuration() {
		return duration;
	}
	
	/** Sets the remaining duration of this buff. If the duration is
	 * zero then the buff is permanent.  **/
	public void setDuration(int duration) {
		this.duration = duration;
	}
	
	/** Returns true if the battle buff has the ability to block the 
	 * targets strategy. **/
	public boolean isBlockingBuff() {
		return (type == BattleBuffType.FROST);
	}
	
	/** Returns true if the battle buff has a battle action factory attached
	 * to it. **/
	public boolean isActionBuff() {
		return (buffActionFactory != null);
	}
	
	/** Returns the battle action factory attached to the battle buff. **/
	public BattleActionFactory getActionFactory() {
		return buffActionFactory;
	}

}
